package com.zhkj.txg.module.product.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zhkj.lib.config.BASE_URL
import com.zhkj.lib.utils.SpanUtil
import com.zhkj.txg.R
import com.zhkj.txg.module.product.entity.Groups
import com.zhkj.txg.utils.ImageUtils

class ProductRecommendAdapter : BaseQuickAdapter<Groups, BaseViewHolder>(R.layout.item_product_goods) {

    override fun convert(helper: BaseViewHolder, item: Groups) {
        val imageView = helper.setText(R.id.tvGoodsTitle, item.goodsName)
            .setText(R.id.tvGoodsPrice, SpanUtil.setMoneySymbol(item.price, false))
            .getView<ImageView>(R.id.ivGoodsThumb)
        ImageUtils.loadImage(
            context, imageView,
            if (item.image.startsWith("http")) item.image else BASE_URL + item.image
        )
    }
}